//
//  EPUB_XML_Parser.m
//  Capstone Project
//
//  Created by Brian Gilreath on 11/24/10.
//  Copyright 2010 GilreathCapstone. All rights reserved.
//

#import "EPUB_Contents_XML_Parser.h"


@implementation EPUB_Contents_XML_Parser

@synthesize rootFile;

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName 
  namespaceURI:(NSString *)namespaceURI 
 qualifiedName:(NSString *)qName 
	attributes:(NSDictionary *)attributeDict {
    if ( [elementName isEqualToString:@"rootfile"]) {
		if (!rootFile)
			rootFile = [[NSMutableArray alloc] init];
		[rootFile addObject:attributeDict];
		// [rootfile addObject:bleck];
        return;
    } else {
		NSLog(@"Have not dealt with element of type: %@", elementName);
	}
}

- (NSString *) getPathOfOEBPS{
	for (NSDictionary *i in rootFile){
		NSString *mediaType = [i valueForKey:@"media-type"];
		if ([mediaType isEqualToString:@"application/oebps-package+xml"]) {
			NSString *res = [i valueForKey:@"full-path"];
			if (res != nil) {
				return res;
			} else {
				break;
			}

		}
	}
	return nil;
}
@end
